//package com.fr.elastic;
//
//import java.net.InetAddress;
//import java.net.UnknownHostException;
//
//import org.apache.lucene.queryparser.xml.builders.BooleanQueryBuilder;
//import org.elasticsearch.action.admin.indices.alias.Alias;
//import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
//import org.elasticsearch.action.bulk.BulkRequestBuilder;
//import org.elasticsearch.action.search.SearchRequest;
//import org.elasticsearch.action.search.SearchRequestBuilder;
//import org.elasticsearch.client.AdminClient;
//import org.elasticsearch.client.ClusterAdminClient;
//import org.elasticsearch.client.IndicesAdminClient;
//import org.elasticsearch.client.transport.TransportClient;
//import org.elasticsearch.cluster.node.DiscoveryNode;
//import org.elasticsearch.common.geo.GeoDistance;
//import org.elasticsearch.common.settings.Settings;
//import org.elasticsearch.common.settings.Settings.Builder;
//import org.elasticsearch.common.xcontent.XContentBuilder;
//import org.elasticsearch.index.query.QueryBuilder;
//import org.elasticsearch.index.query.QueryBuilders;
//import org.elasticsearch.search.aggregations.AggregationBuilders;
//import org.elasticsearch.search.aggregations.Aggregations;
//
//import com.mongodb.bulk.IndexRequest;
//
//public class ESClient {
//	private static TransportClient client = null;
//	static {
//		try {
//			client = TransportClient.builder()
//			    .settings(Settings.builder()
//			        .put("cluster.name", "master")
//			        .build())
//			    .build()
//			    .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
//		} catch (UnknownHostException e) {
//			e.printStackTrace();
//		}
//	}
//	public static void main(String[] args) {
////		AdminClient admin = client.admin();
////		for(DiscoveryNode d : client.connectedNodes()){
////			System.out.println(d.getHostAddress());
////		}
////		IndicesAdminClient iclient = admin.indices();
////		ClusterAdminClient cclient = admin.cluster();
////		CreateIndexRequest request = new CreateIndexRequest("furong");
////		Builder settingsBuilder = Settings.settingsBuilder();
////		settingsBuilder.put("", 2);
////		
////		request.settings(settingsBuilder);//settings
//////		request.mapping("aaa", source); //mappings
////		request.alias(new Alias("test"));
////		iclient.create(request);
////		client.search();
////		client.index(request);
////		client.update(request);
////		client.delete(request);
//	    QueryBuilder query = QueryBuilders.geoDistanceRangeQuery("location")
//            .point(Double.parseDouble("12"), Double.parseDouble("23"))
//            .gt(0)
//            .lte(5*1000)
//            .geoDistance(GeoDistance.PLANE);
//		SearchRequestBuilder sr = client.prepareSearch("").setFrom(0).setSize(5).setQuery(query);
//		System.out.println(sr);
//		
//	}
//}
